class ScorePanel {
  public score: number = 0
  public level: number = 1
  public scoreEle: HTMLElement
  public levelEle: HTMLElement
  constructor(public maxLevel: number = 10, public upScope: number = 10) {
    this.scoreEle = document.getElementById('score')!
    this.levelEle = document.getElementById('level')!
    this.maxLevel = maxLevel
    this.upScope = upScope
  }

  addScore() {
    this.score += 1
    this.scoreEle.innerHTML = `${this.score}`
    // 每10分升级一次
    if(this.score % this.upScope === 0) this.levelUp()
  }

  levelUp() {
    if(this.level < this.maxLevel) {
      this.levelEle.innerHTML = `${++this.level}`
    }
  }
}

export default ScorePanel